<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<div class="aui-text-desc aui-gutter-column-lg">{{ 'protection_big_data_register_tip_label' | i18n }}</div>
<lv-form [formGroup]="formGroup" class="formGroup node-ip-container">
    <lv-form-item>
        <lv-form-label lvRequired>
            {{'common_name_label' | i18n}}
        </lv-form-label>
        <lv-form-control [lvErrorTip]="nameErrorTip">
            <input lv-input type="text" formControlName="name" />
        </lv-form-control>
    </lv-form-item>
    <lv-form-item *ngIf="data.isHbase">
        <lv-form-label [lvRequired]="!data.uuid">hbase-site.xml</lv-form-label>
        <lv-form-control>
            <lv-upload lvAccept=".xml" lvShowUpload="false" [lvFilters]='hbaseFilters'
                [lvPlaceholder]="uploadPlaceholder" (lvFilesChange)="filesChange($event, 'hbase')"></lv-upload>
        </lv-form-control>
    </lv-form-item>
    <lv-form-item>
        <lv-form-label [lvRequired]="!data.uuid">hdfs-site.xml</lv-form-label>
        <lv-form-control>
            <lv-upload lvAccept=".xml" lvShowUpload="false" [lvFilters]='hdfsFilters'
                [lvPlaceholder]="uploadPlaceholder" (lvFilesChange)="filesChange($event, 'hdfs')"></lv-upload>
        </lv-form-control>
    </lv-form-item>
    <lv-form-item>
        <lv-form-label [lvRequired]="!data.uuid">core-site.xml</lv-form-label>
        <lv-form-control>
            <lv-upload lvAccept=".xml" lvShowUpload="false" [lvFilters]='coreFilters'
                [lvPlaceholder]="uploadPlaceholder" (lvFilesChange)="filesChange($event, 'core')"></lv-upload>
        </lv-form-control>
    </lv-form-item>
    <lv-form-item>
        <lv-form-label lvRequired>
            {{'protection_auth_mode_label' | i18n}}
            <ng-container *ngIf="data.isHbase">
                <i lv-icon="aui-icon-help" lv-tooltip="{{'protection_hbase_auth_mode_tips_label' | i18n}}"
                    lvTooltipTheme="light" class="configform-constraint" lvColorState='true'></i>
            </ng-container>
        </lv-form-label>
        <lv-form-control [lvErrorTip]="baseUtilService.requiredErrorTip">
            <lv-select formControlName="loginMode" [lvOptions]='authOptions' lvValueKey='value'>
            </lv-select>
        </lv-form-control>
    </lv-form-item>
    <ng-container *ngIf="clusterAuthType.kerberos.value === formGroup.value.loginMode">
        <lv-form-item>
            <lv-form-label lvRequired>
                Kerberos
                <i lv-icon="aui-icon-help" [lv-tooltip]="tipsTemplate" lvTooltipTheme="light"
                    class="configform-constraint" lvColorState='true'></i>
                <ng-template #tipsTemplate>
                    <span [innerHTML]="kerberosTips"></span>
                </ng-template>
            </lv-form-label>
            <lv-form-control [lvErrorTip]="baseUtilService.requiredErrorTip">
                <lv-group lvGutter="8px">
                    <lv-select formControlName="kerberosId" [lvOptions]='kerberosOptions' lvValueKey='kerberosId'
                        lvShowFilter lvFilterKey='label' lvFilterMode='contains'>
                    </lv-select>
                    <button lv-button (click)="createKerberos()" pmpermission pmOperation='CreateKerberos'>
                        {{ 'common_create_label' | i18n }}
                    </button>
                </lv-group>
                <div style="width: 75%;" *ngIf="formGroup?.get('kerberosId').status === 'VALID' && !!data?.isHbase">
                    <i style="display: inline-block; margin-right: 4px;" lv-icon="lv-icon-status-info"
                        lvColorState="true" class="type-icon"></i>
                    <span class="form-tips aui-text-desc">
                        {{ 'protection_kerberos_simple_tips_label' | i18n }}
                    </span>
                </div>
            </lv-form-control>
        </lv-form-item>
    </ng-container>
    <ng-container *ngIf="clusterAuthType.system.value === formGroup.value.loginMode">
        <lv-form-item>
            <lv-form-label lvRequired>
                {{'common_username_label' | i18n}}
                <i lv-icon="aui-icon-help" lv-tooltip="{{'protection_register_cluster_user_tip_label' | i18n}}"
                    lvTooltipTheme="light" class="configform-constraint" lvColorState='true'></i>
            </lv-form-label>
            <lv-form-control [lvErrorTip]="nameErrorTip">
                <input lv-input type="text" formControlName="username" />
            </lv-form-control>
        </lv-form-item>
    </ng-container>
    <lv-form-item>
        <lv-form-label lvRequired>
            {{'protection_proxy_host_label' | i18n}}
        </lv-form-label>
        <lv-form-control>
            <aui-agent-select [lvOptions]="proxyHostOptions" formControlName='agents' lvValueKey='value'
                lvMode="multiple"></aui-agent-select>
        </lv-form-control>
    </lv-form-item>
    <!-- hbase是否备份分裂表 -->
    <lv-form-item *ngIf="data?.isHbase && isSupport">
        <lv-form-label lvRequired>
            {{ 'protection_hbase_register_division_table_label' | i18n }}
            <i lv-icon="aui-icon-help" lv-tooltip="{{'protection_hbase_register_division_table_tips_label' | i18n}}"
                lvTooltipTheme="light" class="configform-constraint" lvColorState='true'></i>
        </lv-form-label>
        <lv-form-control>
            <lv-switch formControlName="isBackupDivisionTable"></lv-switch>
        </lv-form-control>
    </lv-form-item>
    <!-- hdfs Alc备份 -->
    <lv-form-item *ngIf="!data?.isHbase">
        <lv-form-label>
            {{'explore_acl_backup_label' | i18n}}
            <i lv-icon="aui-icon-help" lv-tooltip="{{'protection_acl_help_label' | i18n}}" lvTooltipTheme="light"
                class="configform-constraint" lvColorState='true'></i>
        </lv-form-label>
        <lv-form-control>
            <lv-switch formControlName='isBackupACL'></lv-switch>
        </lv-form-control>
    </lv-form-item>
</lv-form>